/**
 * GeneralRankingMethod.java
 * ************************** 
 * @date May 5, 2011
 * @author Michele Tamburini
 * 
 * **************************
 */
package gossipServices.bootstraping.tman.rankingMethods;

import gossipServices.basic.nodeDescriptors.NodeDescriptor;
import gossipServices.bootstraping.tman.TManRankingMethod;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * This class provides some facilities in order to implement
 * the TManRankingMethod interface. 
 * The incoming NodeDescriptors are disposed in a list of pair
 * where an int value representing the rank value is associated
 * to each NodeDescriptor. 
 * The ranking method will take advantage of these rank values
 * in order to produce a sorted view in output.
 *
 */
public abstract class GeneralRankingMethod implements TManRankingMethod {

	protected List<RankingPair> pairsList;
	protected int targetViewSize_K;
	
	public GeneralRankingMethod(int targetViewSize){
		this.targetViewSize_K = targetViewSize;
	}
	
	@Override
	public int getTargetViewSize_K() {
		return targetViewSize_K;
	}
	
	@Override
	public void setTargetViewSize_K(int k){
		this.targetViewSize_K = k;
	}
	
	protected List<NodeDescriptor> extracNodeFromPairs(){
		List<NodeDescriptor> list = new ArrayList<NodeDescriptor>();
		for(RankingPair rp : pairsList)
			list.add(rp.getNode());
		return list;
	}
	
	// for debug only!!
	public List<RankingPair> getPairsList(){
		return pairsList;
	}


}
